package com.qf.controller;

import com.qf.pojo.TBteacher;
import com.qf.service.TeacherService;
import com.qf.service.impl.TeacherServiceImpl;
import netscape.javascript.JSObject;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/findAll")
public class FindAllTecherController extends HttpServlet {


    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.声明Service
        TeacherService teacherService = new TeacherServiceImpl();
        //2.执行方法
        List<TBteacher> tBteacherList = teacherService.findAll();
        //返回
       req.setAttribute("teacherlist",tBteacherList);
       //请求转发
        //请求 的重定向
        //转发 重定向区别
        //1.转发时可以携带数据。重定向不能携带
        //2.转发时url不发生变化。重定向时，url会改变
       req.getRequestDispatcher("teacherlist.jsp").forward(req,resp);
    }


}
